#include "stdafx.h"
#include "QProgressSlider.h"

QProgressSlider::QProgressSlider(QWidget *parent)
	: QDialog(parent)
{
	ui.setupUi(this);
	ui.horizontalSlider->setMinimum(0);
	ui.horizontalSlider->setMaximum(100);
	m_isCancel = false;
}

QProgressSlider::~QProgressSlider()
{
}


void QProgressSlider::on_cmdCancel_clicked()
{

	m_isCancel = true;
	this->close();

}

void QProgressSlider::on_cmdOK_clicked()
{
	m_isCancel = false;
	this->close();
}

void QProgressSlider::SetScope(QDate tBegin, QDate tTo)
{
	m_tFrom = tBegin;
	m_tTo = tTo;
	on_horizontalSlider_valueChanged();
}
QDate QProgressSlider::GetTime()
{
	float delta = (ui.horizontalSlider->value()*0.01);
	qint64 t = (m_tTo.toJulianDay() - m_tFrom.toJulianDay())*delta + m_tFrom.toJulianDay();
	return QDate::fromJulianDay(t);
}

void QProgressSlider::on_horizontalSlider_valueChanged()
{
	QDate tNow = GetTime();
	ui.dateEdit->setDate(tNow);
}